<template>
  <div>
    <div class="outer">
      <h2>List</h2>
      <button @click="addData">向父组件发送数据</button>
    </div>
  </div>
</template>

<script>
export default {
  name: "List",
  data() {
    return {
      list: [
        { name: "xiaoming", age: 18 },
        { name: "xiaowang", age: 19 },
        { name: "xiaoli", age: 20 },
      ],
    };
  },
  methods: {
    addData(){
        //this.$emit触发当前实例上的自定义事件。附加参数都会传给监听器回调。
        this.$emit('atguigu',this.list)
    },
    destroyList(){
      //卸载list组件
    }
  },
};
</script>

<style scoped>
.outer{
    height: 200px;
    margin: 30px;
    background: pink;
}
</style>
